from django.conf.urls import url
from .views import statistical, users, image, sku, spu, order
from rest_framework_jwt.views import obtain_jwt_token
from rest_framework.routers import DefaultRouter
urlpatterns = [
    # 使用 rest jwt 提供的自动签发token的视图
    # 由于自动签发的视图只返回 token 自定义返回信息 utils.py
    # 并修改配置文件 JWT_RESPONSE_PAYLOAD_HANDLER
    url(r"^authorizations/$", obtain_jwt_token),

    # 用户总数统计
    url(r"^statistical/total_count/$", statistical.UserTotalCountView.as_view()),

    # 日活用户总数
    url(r"^statistical/day_active/$", statistical.UserDailyActiveCountView.as_view()),

    # 日增用户
    url(r"^statistical/day_increment/$", statistical.UserDailyAddView.as_view()),

    # # 日下单用户数量
    url(r"^statistical/day_orders/$", statistical.UserDailyOrderCountView.as_view()),
    #
    # 月增用户
    url(r"^statistical/month_increment/$", statistical.UserMonthCountView.as_view()),
    #
    # # 日分类商品访问统计
    url(r"^statistical/goods_day_views/$", statistical.UserCategoryCountAPIView.as_view()),

    # 查询用户 增加用户
    url(r"^users/$", users.UserListCreateAPIView.as_view()),

    # 保存图片中的 sku信息
    url(r"^skus/simple/$", image.SKUListView.as_view()),

    # sku管理 增加商品 获取三级分类skus/categories/
    url(r"^skus/categories/$", sku.ThreeCategoryListView.as_view()),

    # SPU表名称数据
    url(r"^goods/simple/$", sku.SPUSimpleView.as_view()),

    # 获取spu规格信息
    url(r"^goods/(?P<pk>\d+)/specs/$", sku.SPUSpecsView.as_view()),



]

# 图片管理视图集
router = DefaultRouter()
router.register("skus/images", image.ImageViewSet, basename="images")
urlpatterns += router.urls

# skus 管理 skus
router = DefaultRouter()
router.register("skus", sku.SKUViewSet, basename="skus")
urlpatterns += router.urls

# spu表格管理 goods/
router = DefaultRouter()
router.register("goods", spu.SPUGoodsViewSet, basename="goods")
urlpatterns += router.urls

# 订单管理 orders
router = DefaultRouter()
router.register("orders", order.OrdersViewSet, basename="orders")
urlpatterns += router.urls